package cn.zktr.Personnel.common;

import java.io.IOException;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Time;
import java.util.Calendar;

public class Shijian {
	public  long getNetworkTime() {
        try {
            URL url=new URL("http://www.baidu.com");
            URLConnection conn=url.openConnection();
            conn.connect();
            long dateL=conn.getDate();
            return dateL;
        }catch (MalformedURLException e) {
            e.printStackTrace();
        }catch (IOException e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return 0 ;
    
	}
	public BigDecimal getyuansuan(Time date1,Time date2) {
		Calendar cal1=Calendar.getInstance();
		cal1.setTime(date1);
		Calendar cal2=Calendar.getInstance();
		cal2.setTime(date2);
		int h1 =cal1.get(Calendar.HOUR_OF_DAY);    
		int m1 =cal1.get(Calendar.MINUTE);    
		int s1 =cal1.get(Calendar.SECOND);  
		int h2 =cal2.get(Calendar.HOUR_OF_DAY);    
		int m2 =cal2.get(Calendar.MINUTE);    
		int s2 =cal2.get(Calendar.SECOND);  
		return new BigDecimal((h1-h2)+(m1-m2)/60+(s1-s2)/3600);
	}
	
}
